dnl Creates and Atom XML file with all the blog posts.
dnl The selection of what gets included is specific to the way texi2html produces HTML,
dnl and not very robust: it depends on the usage of the @date macro (this "flags") pages
dnl for inclusion through the HTML id that is inserted).
include(`foreachq.m4')dnl
include(`config.m4')dnl
define(`__timestamp', esyscmd(date --iso-8601=seconds | tr -d \\n))dnl
<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-GB" xmlns="http://www.w3.org/2005/Atom" xmlns:webfeeds="http://webfeeds.org/rss/1.0">
  <title>__site_title</title>
  <subtitle>__site_subtitle</subtitle>
  <id>https://__site_url</id>
  <link href="https://__site_url/atom.xml" rel="self" type="application/atom+xml" />
  <link href="https://__site_url" rel="alternate" type="text/html" />
  <author>
    <name>__author_name</name>
  </author>
  <updated>__timestamp</updated>
  <webfeeds:cover image="images/cyber1.jpg" />
  <webfeeds:icon>images/favicon.png</webfeeds:icon>
  <webfeeds:logo>images/cyber.png</webfeeds:logo>
  <webfeeds:accentColor>67a43e</webfeeds:accentColor>
  <webfeeds:related layout="card" target="browser"/>
foreachq(`__file', `__html_files',`dnl
changequote(`[', `]')dnl
define([__article_date], esyscmd([awk "/id=\"_article_date\"/ { match($ 0, /_article_date\">(.*)</, a); print \"[[]\" a[1] \"[]]\"}"] __file|tr -d \\n))dnl
define([__article_date_iso],esyscmd(date --iso-8601=seconds --date=__article_date | tr -d \\n))dnl
dnl define([__title], esyscmd([awk "/class=\"section\"/ { gsub(/&.*;/,\"\"); match($ 0, /h3 class=\"section\" .*>(.*)<\/h3>/, a); print \"[[]\" a[1] \"[]]\"}"] __file| tr -d \\n))dnl
define([__title], esyscmd([awk "/<title>/ { gsub(/&.*;/,\"\"); sub(/.*<title>/, \"\"); sub(/<\/title>.*/, \"\"); print \"[[]\" $ 0 \"[]]\" }"] __file| tr -d \\n))dnl
define([__page],esyscmd(basename __file|tr -d \\n))
define([__body_content], esyscmd([awk "/<a class=\"index.*>/,/<span class=\"program-in-footer\"/ { print \"[\" $ 0  \"]\"} "] __file | tidy --doctype omit --show-body-only yes 2>/dev/null | tr \\n " "))dnl
  <entry>
    <author>
      <name>__author_name</name>
    </author>
    <title>__title</title>
    <link href="http://__site_url/__page" rel="alternate" type="text/html"/>    
    <id>https://__site_url/__page</id>
    <published>__article_date_iso</published>
    <updated>__article_date_iso</updated>
changequote dnl    
    <content type="html"><![CDATA[__body_content]]></content>
   dnl   <summary><![CDATA[__body_content]]></summary>
   </entry>')
</feed>

